package com.zlm.website.controller;

import com.zlm.common.base.BaseController;
import com.zlm.common.dto.JsonResultDto;
import com.zlm.website.service.entity.WebsiteMessageDO;
import com.zlm.website.service.service.WebsiteMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 官网留言controller
 * @Author: duyufu
 * @Date: 2019/4/14 11:38
 */
@RestController
@RequestMapping(value = "/message")
public class WebsiteMessageController extends BaseController {
    @Autowired
    private WebsiteMessageService websiteMessageService;

    /**
     * 添加官网留言
     * @param message
     * @return
     */
    @PostMapping("/insertWebsiteMessage")
    @ResponseBody
    public JsonResultDto insertWebsiteMessage(WebsiteMessageDO message){
        //测试用
        try {
            message.setCreateUser("admin");
            message.setLstUpdUser("admin");
            websiteMessageService.insertWebsiteMessage(message);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }
}
